package com.job.client.common.rabbitmqConfig;

import com.job.client.model.message.constant.ChatLogRabbitmqConstant;
import com.job.client.model.rabbitmq.MessageConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqChatLogConfig {
    @Bean
    public Exchange EXCHANGE_CHAT_LOG(){
        return ExchangeBuilder
                .directExchange(ChatLogRabbitmqConstant.EXCHANGE_CHAT_LOG) // 直连交换机，根据key匹配
                .durable(true).build();  // 持久化
    }
    @Bean
    public Queue QUEUE_CHAT_LOG_MESSAGE(){
        return new Queue(ChatLogRabbitmqConstant.QUEUE_CHAT_LOG_MESSAGE);
    }
    @Bean
    public Binding BINDING_QUEUE_CHAT_LOG_MESSAGE(Queue QUEUE_CHAT_LOG_MESSAGE, Exchange EXCHANGE_CHAT_LOG){
        return BindingBuilder.bind(QUEUE_CHAT_LOG_MESSAGE)
                .to(EXCHANGE_CHAT_LOG)
                .with(ChatLogRabbitmqConstant.ROUTINGKEY_CHAT_LOG_MESSAGE).noargs();
    }
    @Bean
    public Queue QUEUE_CHAT_LOG_ADMIN(){
        return new Queue(ChatLogRabbitmqConstant.QUEUE_CHAT_LOG_ADMIN);
    }
    @Bean
    public Binding BINDING_QUEUE_CHAT_LOG_ADMIN(Queue QUEUE_CHAT_LOG_ADMIN, Exchange EXCHANGE_CHAT_LOG){
        return BindingBuilder.bind(QUEUE_CHAT_LOG_ADMIN)
                .to(EXCHANGE_CHAT_LOG)
                .with(ChatLogRabbitmqConstant.ROUTINGKEY_CHAT_LOG_ADMIN).noargs();
    }
}
